package com.leetcode;
@SuppressWarnings("all")
public class L0701 {
    public TreeNode searchBST(TreeNode root, int val) {
        if (root==null)
            return null;
        return search(root,val);
    }

    public TreeNode search(TreeNode root,int val){
        if (root.val==val)
            return root;
        if (root.val>val){
            if (root.left!=null)
                return search(root.left,val);
        }else {
            if (root.right!=null)
                return search(root.right,val);
        }
        return null;
    }
}